package com.hzhjhh.view.manageView.menus.purchase.purchaseOrder;

import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.view.manageView.menus.purchase.PurchaseOrderDialog;
import com.hzhjhh.view.manageView.menus.purchase.constant.ShowConstants;

/**
 * 菜单栏初始化-采购-采购表弹出框-删除按钮
 * 
 * @author 12083
 *
 */
public class DeleteBt {

	/**
	 * 按钮
	 */
	public static JButton btInit(PurchaseOrderDialog stockDialog) {
		JButton delete = new JButton();
		delete.setBounds(244, 93, 83, 25);
        delete.setText("删除");
        delete.addActionListener(event -> {
        	int row = stockDialog.getJTable1().getSelectedRow(); //得到选中行数
        	if (row < 0) {
				// 没有选择任意一行，弹出提示框
        		JOptionPane.showMessageDialog(stockDialog, "请选择要删除的行后，再执行删除操作", "提示", JOptionPane.INFORMATION_MESSAGE);
        		return;
			}
            Vector<Vector<String>> inserAll = stockDialog.getInserAll();
            inserAll.remove(row); //删掉选中的数据
//            jTable1 = Mytable.maketable(inserAll, ShowConstants.HEAD_NAME); //显示内容
            stockDialog.getJScrollPane1().getViewport().add(Mytable.maketable(inserAll, ShowConstants.PURCHASE_HEAD_NAME)); //把表装入容器
        });
		return delete;
	}
}
